import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { PostDto } from 'src/app/models/sys/post.dto';

@Component({
  selector: 'app-post-detail',
  templateUrl: './post-detail.component.html',
  styleUrl: './post-detail.component.less'
})
export class PostDetailComponent implements OnInit {
  @Input() postSubject = new BehaviorSubject<PostDto>(new PostDto());
  @Output() detailEvent = new EventEmitter<boolean>();

  post?: PostDto;

  ngOnInit(): void {
    this.postSubject.subscribe((value) => {
      this.post = value;
    });
  }

  onClose(event: UIEvent) {
    event.preventDefault();

    this.detailEvent.emit(true);
  }
}
